package com.web709.AutoFill;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

@Component
public class AutoFillHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //插入时自动填充createTime和updateTime
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime", LocalDateTime.now());


    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //更新时自动填充updateTime
        metaObject.setValue("updateTime", LocalDateTime.now());

    }
}
